package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.TransportApiApplyThirdparty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2022-04-10 09:47:59
 */
@Repository
public class TransportApiApplyThirdpartyDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(TransportApiApplyThirdpartyDao.class);

    public TransportApiApplyThirdparty insert(final TransportApiApplyThirdparty transportApiApplyThirdparty) {
        insert("TransportApiApplyThirdparty.insert", transportApiApplyThirdparty);
        return transportApiApplyThirdparty;
    }

    public Boolean updateInfoById(final TransportApiApplyThirdparty transportApiApplyThirdparty) {
        return update("TransportApiApplyThirdparty.updateInfoById", transportApiApplyThirdparty) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("TransportApiApplyThirdparty.updateInfoByQuery", query) > 0;
    }

    public TransportApiApplyThirdparty selectById(final Integer id, final Integer entId) {
        Query query = Query.noPage();
        query.put("id", id);
        query.put("entId", entId);
        return queryForObject("TransportApiApplyThirdparty.selectById", query);
    }

    public TransportApiApplyThirdparty selectById(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return queryForObject("TransportApiApplyThirdparty.selectWithoutId", query);
    }

    public List<TransportApiApplyThirdparty> selectByQuery(final Query query) {
        return queryForList("TransportApiApplyThirdparty.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("TransportApiApplyThirdparty.countByQuery", query);
    }

    public Boolean deleteById(final Integer id, final Integer entId) {
        TransportApiApplyThirdparty transportApiApplyThirdparty = new TransportApiApplyThirdparty();
        transportApiApplyThirdparty.setDeleteFlag(1);
        transportApiApplyThirdparty.setId(id);
        transportApiApplyThirdparty.setEntId(entId);

        return update("TransportApiApplyThirdparty.updateInfoById", transportApiApplyThirdparty) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("TransportApiApplyThirdparty.deleteById", query) > 0;
    }
}